package com.xianzhi.service.impl;

import com.xianzhi.bean.Users;
import com.xianzhi.dao.UsersDao;
import com.xianzhi.dto.UsersDto;
import com.xianzhi.service.UsersService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by foreknow on 2021/2/4.
 */
@Service
public class UserServiceImpl implements UsersService {
    @Autowired
    private UsersDao usersDao;

    @Value("F:/software/apache-tomcat-9.0.41/webapps/upload/ad/")
    private String adImageSavePath;

    @Override
    public List<UsersDto> searchByPage(UsersDto userDto) {
        List<UsersDto> result = new ArrayList<>();
        Users condition = new Users();

        BeanUtils.copyProperties(userDto,condition);
        List<Users> usersList = usersDao.selectByPage(condition);

        for (Users users:usersList){
            UsersDto usersDtoTemo = new UsersDto();
            BeanUtils.copyProperties(users,usersDtoTemo);
            result.add(usersDtoTemo);
        }
        return result;
    }
}
